package com.tju.backend.plugin.t_io_server.handler;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.tju.backend.plugin.common.Push;
import com.tju.backend.plugin.common.SPPacket;
import com.tju.backend.plugin.common.intf.AbsCommonBsHandler;
import com.tju.backend.utils.result.ResultEnum;
import com.tju.backend.utils.result.ResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.tio.core.ChannelContext;

@Slf4j
@Component
public class AgvData extends AbsCommonBsHandler {
    @Override
    public void handler(SPPacket packet, String bsBody, ChannelContext channelContext) throws Exception {
        String msg = new String(packet.getBody(), "UTF-8");
        msg = StringUtils.strip(msg, "AGV");
        JSONObject jsonObject = JSONUtil.parseObj(msg);
        log.info("AGV数据" + msg);
        Push.push(ResultUtil.success(ResultEnum.AGV, jsonObject));
    }
}
